import pytest
from calculate import *
# @pytest.fixture()
# def connectdb():
#     print("连接数据库操作")
#     yield "搜索结果"
#     print("断开连接")
#
# @pytest.fixture()
# def login():
#     print("登录")
#     username = "hogwarts"
#     password = "123"
#     return username,password

@pytest.fixture(scope='class')
def initcalc_class():
    print("--开始计算--")
    clac = Calculate()
    yield clac
    print("\n--计算结束--")

def pytest_collection_modifyitems(session,config,items:list):
    print("这是收集所有测试用例的方法")
    for item in items:
        item.name = item.name.encode('utf-8').decode('unicode-escape')
        item._nodeid = item.nodeid.encode('utf-8').decode('unicode-escape')